package com.sajhasite.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.sajhasite.domain.entity.User;

@Repository
public class UserDao extends AbstractDaoHibernate<User, Long> implements IUserDao {

	@SuppressWarnings("unchecked")
    @Override
	public User findUserByEmail(String email) {
		Query query = getSession().getNamedQuery("findUserByEmail");
		query.setParameter("email", email);
		List<User> list = query.list();
		if(list.isEmpty()) {
			return null;
		}
		return list.get(0);
	}
}
